﻿namespace Sidvall.Security
{
    public class UnauthenticatedExceptionContext
    {
        #region Public Members

        public string Title { get; set; }
        public string Message { get; set; }

        #endregion
        #region Factory Members

        #region CreateContext

        public static UnauthenticatedExceptionContext CreateContext(Sidvall.Security.UnauthenticatedException exception)
        {
            if (exception == null)
                throw new System.ArgumentNullException(nameof(exception));
            return new UnauthenticatedExceptionContext()
            {
                Title = exception.Title,
                Message = exception.Message,
            };
        }

        #endregion
        #region Deserialize

        public static UnauthenticatedExceptionContext Deserialize(string value)
        {
            return Deserialize(value, null);
        }
        public static UnauthenticatedExceptionContext Deserialize(string value, UnauthenticatedExceptionContext defaultValue)
        {
            return Sidvall.Serialization.SerializerManager.Current.TryDeserialize<UnauthenticatedExceptionContext>(value, () =>
            {
                return defaultValue;
            });
        }

        #endregion

        #endregion
        #region Constructors

        public UnauthenticatedExceptionContext()
        {
        }

        #endregion
    }
}
